﻿<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
	<xsl:output media-type="text/plain" method="text" indent="yes" encoding="utf-8" />
    <xsl:template match="/">
        <xsl:text disable-output-escaping="yes"><![CDATA[<!DOCTYPE HTML>]]></xsl:text>
<html>
<head>
<xsl:text disable-output-escaping="yes"><![CDATA[<meta charset="utf-8">]]></xsl:text>
<xsl:text disable-output-escaping="yes"><![CDATA[<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">]]></xsl:text>

<title>Assembly Difference</title>

<xsl:text disable-output-escaping="yes"><![CDATA[<meta name="description" content="">]]></xsl:text>
<xsl:text disable-output-escaping="yes"><![CDATA[<meta name="viewport" content="width=device-width">]]></xsl:text>

<style type="text/css"><xsl:comment>Styles here </xsl:comment></style>

</head>
<body>
	<xsl:apply-templates select="AssemblyDifference" />
	
	<xsl:text disable-output-escaping="yes"><![CDATA[<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>]]></xsl:text>

	<xsl:comment>Local Javascript here </xsl:comment>
	<xsl:text disable-output-escaping="yes"><![CDATA[<script>

		$(document).ready(function() {

			$('tr:even').addClass('even');
			
			$('a.toggle').click(function() {

				var table = $(this).parent().parent().next();

				var newPrompt = '';

				if (table.is(':hidden')) {
					newPrompt = 'Hide';
				} else {
					newPrompt = 'Show';
				}

				table.slideToggle();
				$(this).text(newPrompt);
				
				return false;
			});
		});

	</script>]]></xsl:text>

</body>	
</html>

</xsl:template>

<xsl:template match="AssemblyDifference">
<header>
	<hgroup>
		<h1><xsl:value-of select="@Name" /></h1>
	</hgroup>

	<xsl:call-template name="navigation" />
</header>

<article>
  <header>
    <h2><xsl:value-of select="@Name" /></h2>
    <p><a href="#" class="toggle">Hide</a></p>
  </header>
  <table  summary="Summary of changes between versions of this assembly">
    <caption>Summary of changes</caption>
    <tbody>
      <tr><td>% Churn</td><td><xsl:value-of select="@PercentChurn" /></td></tr>  
	    <tr><td>From</td><td><xsl:value-of select="@From" /></td></tr>
	    <tr><td>To</td><td><xsl:value-of select="@To" /></td></tr>
	    <tr><td><a href="#removed">Removed</a></td><td><xsl:value-of select="count(RemovedTypes/*)"/></td></tr>
	    <tr><td><a href="#obsolete">Obsolete</a></td><td><xsl:value-of select="count(ObsoleteTypes/*)"/></td></tr>
	    <tr><td><a href="#changed">Changed</a></td><td><xsl:value-of select="count(ChangedTypes/*)"/></td></tr>
      <tr><td><a href="#added">Added</a></td><td><xsl:value-of select="count(AddedTypes/*)"/></td></tr>
    </tbody>
  </table>
</article>

<xsl:apply-templates select="RemovedTypes"/>

<xsl:apply-templates select="ObsoleteTypes"/>

<xsl:apply-templates select="ChangedTypes"/>

<xsl:apply-templates select="AddedTypes"/>

	<footer>
		<xsl:call-template name="navigation" />
		<p>Generated by 
      <a>
			<xsl:attribute name="href"><xsl:value-of select="@ProductLink" /></xsl:attribute>
			<xsl:value-of select="@ProductName" /> version <xsl:value-of select="@ProductVersion" />
      </a>
		</p>
	</footer>

</xsl:template>

<xsl:template match="ChangedTypes">

  <xsl:call-template name="write_table">
    <xsl:with-param name="title" select="'Changed Types'" />
    <xsl:with-param name="caption" select="'Types that have changed since the earlier version of this assembly'" />
    <xsl:with-param name="linkid" select="'changed'" />
  </xsl:call-template>

</xsl:template>

<xsl:template match="ObsoleteTypes">

  <xsl:call-template name="write_table">
    <xsl:with-param name="title" select="'Obsolete Types'" />
    <xsl:with-param name="caption" select="'Types marked as obsolete since the earlier version of this assembly'" />
    <xsl:with-param name="linkid" select="'obsolete'" />
  </xsl:call-template>

</xsl:template>

<xsl:template match="RemovedTypes">

  <xsl:call-template name="write_table">
    <xsl:with-param name="title" select="'Removed Types'" />
    <xsl:with-param name="caption" select="'Types removed from the later version of this assembly'" />
    <xsl:with-param name="linkid" select="'removed'" />
  </xsl:call-template>

</xsl:template>

<xsl:template match="AddedTypes">

  <xsl:call-template name="write_table">
    <xsl:with-param name="title" select="'Added Types'" />
    <xsl:with-param name="caption" select="'Types added since the earlier version of this assembly'" />
    <xsl:with-param name="linkid" select="'added'" />
  </xsl:call-template>

</xsl:template>

<xsl:template name="write_table" >
  <xsl:param name="title" />
  <xsl:param name="caption" />
  <xsl:param name="linkid" />

  <article>
    <header><h2>
      <xsl:attribute name="id">
        <xsl:value-of select="$linkid"/>
      </xsl:attribute>
      <xsl:value-of select="$title" /></h2><p><a href="#" class="toggle">Hide</a></p></header>
    <table>
      <xsl:attribute name="summary">
      <xsl:value-of select="$caption" />
      </xsl:attribute>
      <caption><xsl:value-of select="$caption" /></caption>
      <tbody>
      <xsl:apply-templates />
      </tbody>
    </table>
  </article>
</xsl:template>

<xsl:template match="TypeNameReference">
    <tr>
      <td>
        <code>
          <a>
            <xsl:attribute name="href">
              <xsl:value-of select="@SafeName" />.html
            </xsl:attribute>
            <xsl:value-of select="@FullName" />
          </a>
        </code>
      </td>
    </tr>
</xsl:template>

<xsl:template match="Type">
  <tr>
    <td><code><xsl:value-of select="@FullName" /></code></td>
    <xsl:if test="string-length(@Message) != 0">
      <td><xsl:value-of select="@Message" /></td>
    </xsl:if>
  </tr>
</xsl:template>

<xsl:template name="navigation">
<nav>
	<ul>
		<li><a><xsl:attribute name="href"><xsl:value-of select="@SummaryName" />.html</xsl:attribute>Summary</a></li>
	</ul>
</nav>
</xsl:template>

</xsl:stylesheet>
